﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Example15.aspx.cs" Inherits="Chapter36.Example15" %>

<!DOCTYPE html>

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>代码清单 36-15 使用变换</title>
    <meta name="author" content="Adam Freeman" />
    <meta name="description" content="A simple example" />
    <link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
    <style>
        canvas {
            border: thin solid black;
            margin: 4px;
        }

        body > * {
            float: left;
        }
    </style>
</head>
<body>
    <canvas id="canvas" width="400" height="200">Your browser doesn't support the <code>canvas</code> element.</canvas>
    <script>
        var ctx = document.getElementById('canvas').getContext('2d');

        ctx.fillStyle = 'lightgrey';
        ctx.strokeStyle = 'black';
        ctx.lineWidth = 3;

        ctx.clearRect(0, 0, 300, 120);
        ctx.globalAlpha = 1.0;
        ctx.font = '60px sans-serif';
        ctx.fillText('Hello', 10, 100);
        ctx.strokeText('Hello', 10, 100);

        ctx.scale(1.3, 1.3);
        ctx.translate(100, -50);
        ctx.rotate(.5);

        ctx.fillStyle = 'red';
        ctx.globalAlpha = .5;
        ctx.fillRect(100, 10, 150, 100);

        ctx.strokeRect(0, 0, 300, 200);
    </script>
</body>
</html>
